﻿@page "/"
@using Row = BootstrapBlazor.Components.Row
@using WebFile.Share.Data

<PageTitle>@(IsAuthenticated ? $"{User.UserName} : 个人中心" : "主页")</PageTitle>

@if (IsAuthenticated)
{
    <h2>欢迎! @User.UserName</h2>
    <Divider/>
    <Row ItemsPerRow="ItemsPerRow.Four" ColSpan="4">
        @foreach (var item in FolderModels)
        {
            <a href="@item.ToWebUrl()">
                <ContextMenuZone>
                    <ContextMenuTrigger>
                        <Card IsCenter="true" IsShadow="true" class="item">
                            <BodyTemplate>
                                <FileIcon style="font-size: 18px" IconColor="@GetIconColor(item)" Extension="@Path.GetExtension(item.Path)">
                                    <BackgroundTemplate>
                                        <i class="@item.ToFileIcon()"></i>
                                    </BackgroundTemplate>
                                </FileIcon>
                                <h6>@Path.GetFileNameWithoutExtension(item.Path)</h6>
                            </BodyTemplate>
                        </Card>
                    </ContextMenuTrigger>
                    <ContextMenu>
                        <ContextMenuItem Icon="fa-solid fa-file" Text="打开" OnClick="@((_, _) => { return OnOpen(item); })"/>
                        <ContextMenuItem Icon="fa-solid fa-trash" Text="删除" OnClick="@(async (_, _) => await OnDelete(item))"/>
                        <ContextMenuItem Icon="fa-solid fa-cloud-arrow-down" Text="下载" OnClick="@(async (_, _) => await OnDownload(item))"/>
                    </ContextMenu>
                </ContextMenuZone>
            </a>
        }
    </Row>

    <SlideButton Placement="Placement.TopEnd" class="Slide" HeaderText="上传" ShowHeader="true" Icon="fa-solid fa-plus">
        <BodyTemplate>
            <Row ItemsPerRow="ItemsPerRow.Three">
                <ButtonUpload TValue="string" OnChange="@OnUploadFile"
                              ShowUploadFileList="false" BrowserButtonText=""
                              BrowserButtonIcon="fa-solid fa-cloud-arrow-up" BrowserButtonClass="btn-primary">
                </ButtonUpload>
                <Button Icon="fa-solid fa-folder" OnClick="@OnAddFolder"></Button>
            </Row>
        </BodyTemplate>
    </SlideButton>
}
else
{
    <h1>WebFile</h1>
    <p>WebFile是一个云文件管理储存系统，您只要注册、登录账号即可</p>
    <p>WebFile可以让用户在云端存储、管理、分享、下载各种类型的文件，如文档、图片、音乐、视频等</p>
    <p>具有高速、安全、稳定、易用的特点，用户可以随时随地访问自己的文件，无需担心文件丢失或损坏</p>
    <p>WebFile还支持多平台、多设备的同步，方便用户在不同的场景下使用WebFile</p>
}

<style>
    .item{
        height: 200px;
        width: 200px;
    }
    .Slide{
        position:fixed; bottom:0; right: 0;
    }
    h1 {
      font-size: 56px;
      margin-top: 20px;
      margin-bottom: 20px;
      animation: fade-in 1s ease-in-out;
    }
    
    h2 {
      font-size: 48px;
      margin-top: 20px;
      margin-bottom: 20px;
      animation: fade-in 1s ease-in-out;
    }
    
    p {
      font-size: 18px;
    }
</style>